{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "circle = lambda x : x * 3.14 * 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "25.12\n"
     ]
    }
   ],
   "source": [
    "print(circle(4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "add = lambda a, b : a + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n"
     ]
    }
   ],
   "source": [
    "print(add(3, 5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "sub = lambda a, b : a - b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "print(sub(5,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "add3 = lambda a, b, c : a + b + c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "15\n"
     ]
    }
   ],
   "source": [
    "print(add3(4, 5, 6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[] <class 'list'>\n",
      "[1, 2, 3] <class 'list'>\n",
      "[[1, 2, 3], [4, 5, 6]] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "lst = []\n",
    "print(lst, type(lst))\n",
    "lst = [1, 2, 3]\n",
    "print(lst, type(lst))\n",
    "lst = [[1, 2, 3], [4, 5, 6]]\n",
    "print(lst, type(lst))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apple\n",
      "banana\n",
      "cherry\n",
      "cherry\n",
      "banana\n",
      "apple\n"
     ]
    }
   ],
   "source": [
    "#             0         1         2\n",
    "#             -3        -2       -1\n",
    "my_list = [\"apple\", \"banana\", \"cherry\"]\n",
    "\n",
    "print(my_list[0]) # 输出 \"apple\"\n",
    "print(my_list[1]) # 输出 \"banana\"\n",
    "print(my_list[2]) # 输出 \"banana\"\n",
    "print(my_list[-1]) # 输出 \"cherry\n",
    "print(my_list[-2]) # 输出 \"cherry\n",
    "print(my_list[-3]) # 输出 \"cherry"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apple\n",
      "banana\n",
      "cherry\n",
      "dog\n",
      "egg\n"
     ]
    }
   ],
   "source": [
    "#             0         1         2        3     4\n",
    "#              -5     -4          -3      -2        -1\n",
    "my_list = [\"apple\", \"banana\", \"cherry\", 'dog', 'egg']\n",
    "# print(my_list[-1])\n",
    "# print(my_list[-5])\n",
    "# print(my_list[0])\n",
    "\n",
    "for x in my_list:\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['banana', 'cherry']\n",
      "['apple', 'banana', 'cherry', 'orange']\n",
      "['kiwi', 'melon', 'mango']\n",
      "['kiwi', 'melon', 'mango']\n"
     ]
    }
   ],
   "source": [
    "my_list = [\"apple\", \"banana\", \"cherry\", \"orange\", \"kiwi\", \"melon\", \"mango\"]\n",
    "\n",
    "print(my_list[1:3]) # 输出 [\"banana\", \"cherry\"]\n",
    "print(my_list[:4]) # 输出 [\"apple\", \"banana\", \"cherry\",\"orange\"]\n",
    "print(my_list[4:]) # 输出 [\"kiwi\", \"melon\", \"mango\"]\n",
    "print(my_list[-3:]) # 输出 [\"kiwi\", \"melon\", \"mango\"]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
